//
// Created by chizuru on 2025/9/29.
//

#pragma once
#include "DeviceComm.h"
#include "IProtocolCodec.h"

class SensorTPDevice {
public:
    SensorTPDevice(DeviceComm& comm, std::unique_ptr<IProtocolCodec> codec);

    std::vector<std::optional<uint32_t>> readRegisters(uint8_t dev, uint16_t addr, const std::vector<uint16_t>& registerCounts);
    bool writeRegisters(uint8_t dev, uint16_t addr, uint16_t registerCount, const std::vector<uint16_t>& values);


    void setRetryPolicy(const RetryPolicy& rp);
private:
    DeviceComm& comm;
    RetryPolicy retryPolicy;
    std::unique_ptr<IProtocolCodec> codec;
    const std::chrono::milliseconds SERIAL_COMMAND_TRANSMIT_TIME{80};
    const std::chrono::milliseconds SERIAL_COMMAND_TIMEOUT{1000};
    const std::chrono::milliseconds SERIAL_COMMAND_INTER_READ_DELAY{10};
};
